home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / pascal / mouslib8.zip / MOUSETST.PAS < prev    next >
Pascal/Delphi Source File  |  1993-02-25  |  4KB  |  108 lines

  1. (******************************************************************************
  2. *                                  mouseTest                                  *
  3. * This is a simple test program that shows if the mouse is functions, and     *
  4. * demonstrates basic mouse programming using the mouseLib unit.               *
  5. ******************************************************************************)
  6. program mouseTest;
  7.  
  8. uses 
  9.    mouseLib
  10.    ,Crt
  11.    ,Graph
  12. {$ifdef incDrv}
  13.    ,grDriver
  14. {$endif} {include bgi drivers with programs ... }
  15.    ;
  16.  
  17. var 
  18.    gradriver,
  19.    grmode : integer;
  20.    errCode : integer;
  21. const
  22.    crsr   : byte = 0;
  23.  
  24. begin
  25.  
  26.    setVGATextGraphicCursor;
  27.    initMouse;
  28.    setDefaultHandler(left_button_pressed); 
  29.    { this is needed for the handling of the textGraphic cursor ! }
  30.  
  31.      clrScr;
  32.      if not (mouse_present) then begin
  33.      { mouse_present was set by the mouseLib initialization code .. }
  34.           write('mouse not installed');
  35.           exit;
  36.      end;
  37.      case mouse_buttons of
  38.           twoButton : writeLn('MicroSoft mouse Mode');
  39.           threeButton : writeLn('PC mouse Mode');
  40.           else writeLn('UnRecognized mouse mode');
  41.      end; {case}
  42.      writeln('MouseLib demo program, (c) 1992, Ron Loewy.');
  43.      writeln;
  44.      writeln('Move Cursor, Press Right & Left buttons together to continue');
  45.      writeln('             Press any mouse button by itself to recognize');
  46.      window(10, 7, 70, 20);
  47.      if (not vgaTextGraphicCursor) then 
  48.       hardwareTextCursor(10,13); { "normal" text cursor }
  49.      showMouseCursor; { display the cursor }
  50.      repeat
  51.          if getButton(leftButton) = buttonDown then begin
  52.             hideMouseCursor;
  53.             writeLn('Left Button Pressed');
  54.             showMouseCursor;
  55.          end;
  56.          if getButton(rightButton) = buttonDown then begin
  57.             hideMouseCursor;
  58.             writeLn('right Button Pressed');
  59.             showMouseCursor;
  60.          end;
  61.          if getButton(middleButton) = buttonDown then begin
  62.             hideMouseCursor;
  63.             writeLn('Middle Button Pressed');
  64.             showMouseCursor;
  65.          end;
  66.      until (getButton(leftButton) = buttonDown) and
  67.            (getButton(RightButton) = buttonDown);
  68.      hideMouseCursor; { we hide the cursor }
  69.      graDriver := detect;
  70.      initGraph(graDriver, grMode, '');
  71.      errCode := graphResult;
  72.      if (errCode <> grOk) then begin
  73.       writeln(graphErrorMsg(errCode));
  74.       halt(88);
  75.      end;
  76.      setMouseGraph; { fix quircks in Herc. graphic card, disable vgaTextGraph mode }
  77.      initMouse; { let the mouse sense it is in graphic mode }
  78.      outTextXY(10, 10, 'MouseLib demo program, (c) 1992, Ron Loewy.');
  79.      outTextXY(10, 30, 'Press the Right Button to END');
  80.      outTextXY(10, 50, 'Press the Left  Button to switch cursor');
  81.      showMouseCursor; { draw the graphic default arrow cursor }
  82.      setDefaultHandler(LEFT_BUTTON_PRESSED + RIGHT_BUTTON_PRESSED);
  83.      repeat 
  84.       repeat until eventHappened; { wait for event handler }
  85.       eventHappened := false; { and clear for next time ... }
  86.       if (getButton(leftButton) = buttonDown) then begin
  87.          inc(crsr);
  88.          if (crsr > 9) then 
  89.             crsr := 0;
  90.          case crsr of
  91.             0 : setArrowCursor;
  92.             1 : setWatchCursor;
  93.             2 : setUpArrowCursor;
  94.             3 : setLeftArrowCursor;
  95.             4 : setCheckMarkCursor;
  96.             5 : setPointingHandCursor;
  97.             6 : setDiagonalCrossCursor;
  98.             7 : setRectangularCrossCursor;
  99.             8 : setHourGlassCursor;
  100.             9 : setNewWatchCursor;
  101.          end; { case }
  102.       end;
  103.      until (getButton(rightButton) = buttonDown);
  104.      hideMouseCursor;
  105.      closeGraph;
  106.      writeln('MouseLib demo program, (c) 1992, Ron Loewy.');
  107. end.
  108.